package com.tc.config;

import javax.servlet.http.HttpSession;
import javax.websocket.HandshakeResponse;
import javax.websocket.server.HandshakeRequest;
import javax.websocket.server.ServerEndpointConfig;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;


public class GetHttpSessionConfig extends ServerEndpointConfig.Configurator {


    //配置对象，握手请求，握手响应
    @Override
    public void modifyHandshake(ServerEndpointConfig sec, HandshakeRequest request, HandshakeResponse response) {
        //从握手的请求中获取携带的用户信息,只取用户id
        String id=request.getHeaders().get("id").get(0);
        //将用户id保存到配置对象中,键只需要保证唯一即可
        sec.getUserProperties().put(HttpSession.class.getName(),id);

    }
}
